<html>
<head><meta charset="utf-8"><title>Official Backwards Compatibility Guarantee Document? · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html">Official Backwards Compatibility Guarantee Document?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232839917"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232839917" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232839917">(Apr 01 2021 at 23:34)</a>:</h4>
<p>Do we have a page describing what our official backwards compatibility guarantee is outside of the RFC that defined it?</p>



<a name="232845120"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232845120" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232845120">(Apr 02 2021 at 00:36)</a>:</h4>
<p>I'm only aware of the RFCs, a couple blog posts in 2014, and <a href="https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#stability-without-stagnation">the book chapter on releases</a>.</p>



<a name="232845655"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232845655" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232845655">(Apr 02 2021 at 00:44)</a>:</h4>
<p>I feel like we should have it somewhere in the official documentation then.</p>



<a name="232845673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232845673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232845673">(Apr 02 2021 at 00:44)</a>:</h4>
<p>Other than <em>The Book</em></p>



<a name="232845845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232845845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232845845">(Apr 02 2021 at 00:47)</a>:</h4>
<p>Especially if we're modifying it with the reservation RFC.</p>



<a name="232846649"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232846649" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232846649">(Apr 02 2021 at 00:58)</a>:</h4>
<p>Yeah, <a href="https://rust-lang.github.io/rfcs/1105-api-evolution.html">https://rust-lang.github.io/rfcs/1105-api-evolution.html</a> is the only spot that comes to mind for me.</p>



<a name="232847186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232847186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232847186">(Apr 02 2021 at 01:05)</a>:</h4>
<p>Wait, the reservation RFC is modifying it?  I thought it was making all those reserved tokens be tokenizer errors.</p>
<p>Hmm, that's ambiguous in my 3098's guide-level section, at least...</p>



<a name="232847404"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232847404" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232847404">(Apr 02 2021 at 01:08)</a>:</h4>
<p>currently my RFC says that <code>foo#bar</code> will lex as a single token, but result in a compiler error beyond that if <code>foo</code> is not actually used by the language. you would be able to make a macro that consumes <code>foo#bar</code>, but you wouldn't actually be able to do anything with it. I don't think this actually has any impact on stability; adding a new prefix <code>foo#</code> would only make <em>more</em> code compile, yes?</p>



<a name="232847455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232847455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> isHavvy <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232847455">(Apr 02 2021 at 01:09)</a>:</h4>
<p>Hmm, that is true. I guess there are no needed changes to the backwards compatibility then.</p>



<a name="232847458"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232847458" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232847458">(Apr 02 2021 at 01:09)</a>:</h4>
<p>I think it's mostly immaterial whether or not it results an error before or after the tokenizer. I'll take whatever</p>



<a name="232850591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232850591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232850591">(Apr 02 2021 at 02:01)</a>:</h4>
<p>If it's straightforward to do, it might be nice if it were an error in the tokenizer. That seems like an alternative worth documenting in the RFC. Advantage: that would prevent using the reserved space for any other purpose, even by recognizing the tokens in a macro. Disadvantage: that would prevent prototyping language proposals in macros.</p>



<a name="232850615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232850615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232850615">(Apr 02 2021 at 02:01)</a>:</h4>
<p>I'm not sure which of those is a more critical factor. Seems worth documenting the potential trade off there.</p>



<a name="232851297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232851297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232851297">(Apr 02 2021 at 02:12)</a>:</h4>
<p>I'll edit the text to make it a tokenizer error, and mention the current state as an alternative. It's easy to make it leniently accept more code if for whatever reason that turns out to be too strict</p>



<a name="232851538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232851538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232851538">(Apr 02 2021 at 02:16)</a>:</h4>
<p>For the moment, I would actually suggest the reverse: leave the current state, and mention strict errors in the tokenizer as an alternative.</p>



<a name="232851553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232851553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232851553">(Apr 02 2021 at 02:17)</a>:</h4>
<p>I'm leaning towards thinking the ability to prototype via macros probably outweighs the hazard of letting people play in a reserved part of the design space.</p>



<a name="232852218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232852218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232852218">(Apr 02 2021 at 02:29)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span> I can provide text for that change if that'd help.</p>



<a name="232852552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232852552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232852552">(Apr 02 2021 at 02:34)</a>:</h4>
<p>Happy to accept :)</p>



<a name="232853399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232853399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232853399">(Apr 02 2021 at 02:50)</a>:</h4>
<p>Oh, so it can be matched against in a macro, but not put in anything but <code>tt</code> since it wouldn't be an <code>expr</code>/<code>ident</code>/<code>literal</code>/etc?  Sounds interesting.</p>



<a name="232853906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232853906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bstrie <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232853906">(Apr 02 2021 at 02:59)</a>:</h4>
<p>can someone give an example of what they mean by "prototype via macros" in this context?</p>



<a name="232855721"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232855721" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232855721">(Apr 02 2021 at 03:30)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span> Suppose we wanted to implement the <code>throw</code>/<code>fail</code>/<code>yeet</code> construct (to return early with an error). Someone could write a proc macro inside which you could write <code>k#yeet err;</code>, and people could try that out to see what it feels like.</p>



<a name="232859077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232859077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232859077">(Apr 02 2021 at 04:32)</a>:</h4>
<p><span class="user-mention" data-user-id="256342">@bstrie</span> Here's some text for the alternatives section:</p>
<ul>
<li>We could generate an error during tokenization when encountering a reserved sequence without a defined meaning in the compiler. This would prevent macros from making use of reserved tokens, which would make conflicts less likely with future language syntax. However, doing this would also limit the ability to experiment with macros to prototype implementations of new language features for testing purposes. For that reason, this RFC does not propose erroring on reserved syntax in tokenization, and instead just reserves such syntax by specification, allowing future Rust versions to use any such syntax at any time without needing to wait for an edition boundary.</li>
</ul>



<a name="232863502"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232863502" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232863502">(Apr 02 2021 at 05:49)</a>:</h4>
<p>Hmm, "by specification" sounds like the <code>__foo</code> reservation in C++ that's not enforced in any way in any compiler I've used.</p>
<p>The restrictions is stronger than that, right?  It can't be used as anything other than a token, I'd expect.  (Not even as an <code>:expr</code> separator or something.)</p>



<a name="232863605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232863605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232863605">(Apr 02 2021 at 05:51)</a>:</h4>
<p>I <em>think</em> it'd be possible to match it literally, unless we prevent that.</p>



<a name="232863890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232863890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232863890">(Apr 02 2021 at 05:56)</a>:</h4>
<p>Right, only the things that work on every token (matching it literally, <code>stringify!</code>ing, etc)</p>



<a name="232863991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232863991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232863991">(Apr 02 2021 at 05:59)</a>:</h4>
<p>Hmm, that means it'd still break a macro that has <code>( $e:expr ) =&gt; { 1 }, ( k#yeet $f:expr ) =&gt; { 2 }</code> though, wouldn't it...</p>



<a name="232864048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232864048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232864048">(Apr 02 2021 at 06:00)</a>:</h4>
<p>What "it" do you mean in "it'd still break"?</p>



<a name="232929586"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232929586" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232929586">(Apr 02 2021 at 17:44)</a>:</h4>
<p>Once <code>k#yeet</code> became valid in an expression it'd start matching the first arm instead of the second.</p>



<a name="232929682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232929682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232929682">(Apr 02 2021 at 17:45)</a>:</h4>
<p>Sure. But part of the point of reserving syntax is that we no longer need to worry about that second branch on the macro.</p>



<a name="232929769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232929769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232929769">(Apr 02 2021 at 17:46)</a>:</h4>
<p>If a macro is parsing reserved syntax we don't define, it's not forward-compatible and we don't have to worry about breaking it.</p>



<a name="232933284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232933284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232933284">(Apr 02 2021 at 18:15)</a>:</h4>
<p>Is there a way it could be a tokenizer error unless you have a never-going-to-be-stable <code>feature</code> active?  It feels a shame to say "well, we're allowed to break stuff with no warning from the compiler" if there'd be a way we could do better.</p>
<p>Or some sort of "you're allowed to use it but only if there's no overlap of it with <code>$</code> matchers in other arms"?  (Don't know if that's at all feasible...)</p>



<a name="232933357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232933357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232933357">(Apr 02 2021 at 18:15)</a>:</h4>
<p>We don't know how new keywords will be used.</p>



<a name="232933370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232933370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232933370">(Apr 02 2021 at 18:15)</a>:</h4>
<p>Let alone arbitrary other bits of reserved syntax.</p>



<a name="232935218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232935218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232935218">(Apr 02 2021 at 18:31)</a>:</h4>
<p>Yeah, I mean consider if a conflict if there's anything other than another token literal in the other arm.</p>



<a name="232937536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232937536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232937536">(Apr 02 2021 at 18:52)</a>:</h4>
<p>Isn't it the case that this returns true on modern versions of rustc (at all editions), but not on old versions of the compiler (I don't have one around to test)?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">has_async</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$e</span>:<span class="nc">expr</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="kc">true</span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">{})</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="kc">false</span><span class="p">};</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="fm">println!</span><span class="p">(</span><span class="s">"{}"</span><span class="p">,</span><span class="w"> </span><span class="n">has_async</span><span class="o">!</span><span class="p">(</span><span class="k">async</span><span class="w"> </span><span class="p">{}));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="232937575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232937575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232937575">(Apr 02 2021 at 18:52)</a>:</h4>
<p>seems like you can use a trick like this to basically detect any syntax extension at all</p>



<a name="232938194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/232938194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#232938194">(Apr 02 2021 at 18:59)</a>:</h4>
<p>Oh interesting, this returns <code>true</code> on nightly and is a compile error on stable:</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="fm">macro_rules!</span><span class="w"> </span><span class="n">has_or_patterns</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$e</span>:<span class="nc">pat</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="kc">true</span><span class="p">};</span><span class="w"></span>
<span class="w">    </span><span class="p">(</span><span class="cp">$($e</span>:<span class="nc">tt</span><span class="p">)</span><span class="o">*</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{</span><span class="kc">false</span><span class="p">};</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="w">  </span><span class="fm">println!</span><span class="p">(</span><span class="s">"{}"</span><span class="p">,</span><span class="w"> </span><span class="n">has_or_patterns</span><span class="o">!</span><span class="p">(</span><span class="nb">Some</span><span class="p">(</span><span class="mi">1</span><span class="w"> </span><span class="o">|</span><span class="w"> </span><span class="mi">2</span><span class="p">)));</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>
<p>I would guess that this returns <code>false</code> on old versions of the compiler before or patterns were implemented. If you use <code>1 | 2</code> it returns false on nightly and stable.</p>



<a name="233000275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/233000275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Daniel Henry-Mantilla <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#233000275">(Apr 03 2021 at 11:34)</a>:</h4>
<p>So I already mentioned this rpoblem in <span class="user-mention" data-user-id="125270">@scottmcm</span> 's RFC, and a full lexing error was suggested which is sufficient to avoid it.<br>
If, however, we want these to be lexable, then the rules with any <em>parser</em> capture such as <code>:expr</code> need to be more subtle than just  not matching them: they would need to start matching them, but end up erroring, making the macro uncallable (<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=314472db2d136b76eb077a0c355876c6">similar to how a <code>$:expr</code> rule that shadows a <code>$:lifetime</code> one makes the macro unable to be called on lifetimes alone</a>; the larger rule (such as <code>$:expr</code>) always need ro go after the macro's custom syntax rule!)</p>



<a name="233025488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Official%20Backwards%20Compatibility%20Guarantee%20Document%3F/near/233025488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Official.20Backwards.20Compatibility.20Guarantee.20Document.3F.html#233025488">(Apr 03 2021 at 19:04)</a>:</h4>
<p>Oh, clever.  I like that approach -- makes it usable for markers and DSLs, but avoids breaking things when it starts getting used somewhere.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>